package forum.client;
import static org.junit.Assert.*;

import org.junit.Test;

import forum.server.controller.ForumFacade;
import forum.server.domain.Post;
import forum.server.domain.PostContent;
import forum.server.persistence.DataManipulatorProxy;

public class ForumEncodeTest {
	
	

	@Test
	public void testEncode(){
		try{
			DataManipulatorProxy.getInstance().resetDataBase();
			ForumFacade ff = new ForumFacade();
			ff.register("test1", "1234");
			ff.login("test1", "1234");
			Post newPost = ff.addPost("Just for Test", new PostContent("Hello world!!!"));
			ff.replyToPost(newPost.getPostId(), "Reply1", new PostContent("The first reply"));
			String encodedView = ff.viewForum();
			assertTrue(encodedView.contains("test1 <content> Reply1\nThe first reply </content> <replies> </replies>")
					&& encodedView.contains("test1 <content> Just for Test\nHello world!!! </content>"));

		} catch(Exception e){
			e.printStackTrace();
		}
	}

}
